#pragma once

#include "comm/znx_log.h"
#include "comm/znx_defs.h"
#include "comm/znx_pool.h"
#include "comm/znx_array.h"
#include "comm/znx_module.h"
#include "comm/znx_string.h"


typedef struct {
    int                     worker_threads;
    int                     tcp_accepter_threads;
    size_t                  g_mem_freelists_level;
    size_t                  g_aligned_mem_freelists_level;
    size_t                  worker_mem_freelist_level;
    size_t                  worker_aligned_mem_freelists_level;
    znx_str_t               listener_conf_path;
    znx_str_t               http_conf_dir;
    // http_conf_dir + main.yaml
    znx_str_t               http_main_conf_path;
    // http_conf_dir + sites_enabled/main.yaml
    znx_str_t               http_sites_enabled_dir;

    void                    **modules;

    znx_pool_t              *pool;
    znx_str_t               err;
} znx_core_conf_t;


extern znx_core_conf_t      *g_core_conf;

void znx_core_conf_destroy();

znx_bool_t
znx_core_conf_parse(const char *filepath);

#define znx_core_get_module_conf(module)                        \
    g_core_conf->modules[module.index]

#define znx_core_set_module_conf(module, module_conf)           \
    g_core_conf->modules[module.index] = module_conf

